myApp.controller('machinelistController', function ($scope, $uibModal, $stateParams, ngDialog, $http, $filter, $interval, $timeout, $rootScope) {
    $scope.info = {};

    $scope.info.machines = [];
    $scope.getMachine = function () {
        $http.get(ucloud_master_url + '/api/v1/machine/?token_id=' + getTokenId(), {
            headers: {'Accept': 'application/json'}
        }).success(function (data) {
            $scope.info.machines = data.data;
        });
    };
    $scope.getMachine();

    $scope.add = function () {
        window.location.href = '#/menu/addMachine/';
    };
    $scope.startVMs = function (i) {
        openDialog(ngDialog, $scope, "确定要所有虚拟机吗?", true, function (val) {
            if (!val) {
                return;
            }
            $http.get(ucloud_master_url + '/api/v1/machine/startVM?ip=' + i.ip).success(function (data) {
                if (data.success == true) {
                    alert('启动成功，请稍后查看虚拟机启动状态!');
                } else {
                    alert(data.msg);
                }
            })
        });
    };
});